<?php if (!isset($_SESSION)) session_start(); ?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

<title>Koreanet</title>

<!-- Nanum Webfont -->
<style>
* {
	font-family: 'NanumGothic' !important;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script>
 google.load( "webfont", "1" );
 google.setOnLoadCallback(function() {
  WebFont.load({ custom: {
   families: [ "NanumGothic" ],
   urls: [ "http://fontface.kr/NanumGothic/css" ]
  }});
 });
</script>

<script type="text/javascript">
	var reVal;
	var t_categoty;
	
	function requestCategoryData(carte_dil) {
		reVal = getXMLRequestObject();
		reVal.onreadystatechange = onChange;
		t_categoty = carte_dil;

		var params = "category="+t_categoty.toString();
		
		reVal.open("POST", "./ajax/category_management_table.php", true);
		reVal.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		reVal.send(params);
	}

	function getXMLRequestObject() {
		var xmlreq = false;
		if (window.XMLHttpRequest) { //파이어폭스나 맥의 사파리의 경우처리 
			xmlreq = new XMLHttpRequest();
		} else if (window.ActiveXObject) { //IE계열의 브라우져의 경우
			try {
				xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e1) {
				// Failed to create required ActiveXObject
				try {
					// Try version supported by older versions
					// of Internet Explorer
					xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e2) {
					// Unable to create an XMLHttpRequest with ActiveX
				}
			}
		}
		return xmlreq;
	}

	function onChange() {
		// only if req shows "loaded"
		if (reVal.readyState == 4) {
			// only if "OK"
			if (reVal.status == 200) {
				if (reVal.responseText.length < 1) {
					alert("검색 결과가 없습니다.");
					if     (t_categoty == 1) { document.getElementById("position_cat").innerHTML = ""; } 
					else if(t_categoty == 2) { document.getElementById("sosok_cat").innerHTML = ""; }
					else if(t_categoty == 3) { document.getElementById("brno_cat").innerHTML = ""; }
					else if(t_categoty == 4) { document.getElementById("cusm_cat").innerHTML = ""; }
					else if(t_categoty == 9) { document.getElementById("subs_firm").innerHTML = ""; }
					addTableSorter();
				} else {
					if     (t_categoty == 1) { document.getElementById("position_cat").innerHTML = reVal.responseText; }
					else if(t_categoty == 2) { document.getElementById("sosok_cat").innerHTML = reVal.responseText; }
					else if(t_categoty == 3) { document.getElementById("brno_cat").innerHTML = reVal.responseText; }
					else if(t_categoty == 4) { document.getElementById("cusm_cat").innerHTML = reVal.responseText; }
					else if(t_categoty == 9) { document.getElementById("subs_firm").innerHTML = reVal.responseText; }
				}
			} else {
				alert("There was a problem retrieving the XML data:\n" + reVal.statusText);
			}
		}
	}
</script>

<!-- Bootstrap core CSS -->
<link href="./dist/css/bootstrap.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="./css/category.css" rel="stylesheet">

</head>

<body>
<?php include 'header.php';?>
<?php require_once './class/Category.inc';?>
<?php

if ($login == null || $login->getGrade () > 1) {
	echo "<script type='text/javascript'>";
	echo "location.replace('./main.php');";
	echo "</script>";
	exit ();
}
?>

	<div class="container container_bottom">
		<div class="row">
			<div class="col-md-12">
				<h2>분류 관리</h2>
			</div>
		</div>
		<ul class="nav nav-tabs">
			<!-- <li class="active"><a href="#tab1" data-toggle="tab" 
				onClick="requestCategoryData('1')">직책</a></li>-->
			<li class="active"><a href="#tab2" data-toggle="tab"
				onclick="requestCategoryData('2')">차량소속</a></li>
			<li><a href="#tab3" data-toggle="tab"
				onclick="requestCategoryData('3')">지점명</a></li>
			<li><a href="#tab5" data-toggle="tab"
				onclick="requestCategoryData('9')">용차업체</a></li>
			<li><a href="#tab4" data-toggle="tab"
				onclick="requestCategoryData('4')">거래처명</a></li>
		</ul>
		<div class="tab-content">
			<!-- 			<div class="tab-pane active" id="tab1"> -->
			<!-- 				<div class="well"> -->
			<!-- 					직책 삭제 -->
			<!-- 					<form class="form-signin" role="form" -->
			<!-- 						action="./ajax/delete_category_data.php" method="post"> -->
			<!-- 						<input type="hidden" name="cate" id="position_tp" type="text" -->
			<!-- 							class="form-control" value="1"> <select name="cate_value" -->
			<!-- 							id="position_cat" multiple class="form-control" required> -->
			<!-- 						</select> -->
			<!-- 						<button class="btn btn-lg btn-primary" type="submit">삭제</button> -->
			<!-- 					</form> -->
			<!-- 				</div> -->
			<!-- 				<div class="well"> -->
			<!-- 					직책 생성 -->
			<!-- 					<form class="form-signin" role="form" -->
			<!-- 						action="./ajax/create_category_data.php" method="post"> -->
			<!-- 						<input type="hidden" name="cate" type="text" class="form-control" -->
			<!-- 							value="1"> <input name="cate_value" type="text" -->
			<!-- 							class="form-control" placeholder="생성할 직책명을 입력하세요." required> -->
			<!-- 						<button class="btn btn-lg btn-primary" type="submit">생성</button> -->
			<!-- 					</form> -->
			<!-- 				</div> -->
			<!-- 			</div> -->

			<div class="tab-pane active" id="tab2">
				<div class="well">
					차량소속 삭제
					<form class="form-signin" role="form"
						action="./ajax/delete_category_data.php" method="post">
						<input type="hidden" name="cate" id="sosok_tp" type="text"
							class="form-control" value="2"> <select name="cate_value"
							id="sosok_cat" multiple class="form-control" required>
						</select>
						<button class="btn btn-lg btn-primary" type="submit">삭제</button>
					</form>
				</div>
				<div class="well">
					차량소속 생성
					<form class="form-signin" role="form"
						action="./ajax/create_category_data.php" method="post">
						<input type="hidden" name="cate" id="sosok_tp" type="text"
							class="form-control" value="2"> <input name="cate_value"
							type="text" class="form-control" placeholder="생성할 차량소속명을 입력하세요."
							required>
						<button class="btn btn-lg btn-primary" type="submit">생성</button>
					</form>
				</div>
			</div>

			<div class="tab-pane" id="tab3">
				<div class="well">
					지점명 삭제
					<form class="form-signin" role="form"
						action="./ajax/delete_category_data.php" method="post">
						<input type="hidden" name="cate" id="brno_tp" type="text"
							class="form-control" value="3"> <select name="cate_value"
							id="brno_cat" multiple class="form-control" required>
						</select>
						<button class="btn btn-lg btn-primary" type="submit">삭제</button>
					</form>
				</div>
				<div class="well">
					지점명 생성
					<form class="form-signin" role="form"
						action="./ajax/create_category_data.php" method="post">
						<input type="hidden" name="cate" type="text" class="form-control"
							value="3"> <input name="cate_value" type="text"
							class="form-control" placeholder="생성할 지점명을 입력하세요." required>
						<button class="btn btn-lg btn-primary" type="submit">생성</button>
					</form>
				</div>
			</div>
			<div class="tab-pane " id="tab4">
				<div class="well">
					거래처 정보 <input type="hidden" name="cate" type="text"
						class="form-control" value="4"> <select name="cate_value"
						id="cusm_cat" multiple class="form-control" required>
					</select>
				</div>
			</div>
			<div class="tab-pane " id="tab5">
				<div class="well">
					용차업체 삭제
					<form class="form-signin" role="form"
						action="./ajax/delete_category_data.php" method="post">
						<input type="hidden" name="cate" type="text" class="form-control"
							value="8"> <select name="cate_value" id="subs_firm" multiple
							class="form-control" required>
						</select>
						<button class="btn btn-lg btn-primary" type="submit">삭제</button>
					</form>
				</div>
				<div class="well">
					용차업체 생성
					<form class="form-signin" role="form"
						action="./ajax/create_category_data.php" method="post">
						<input type="hidden" name="cate" type="text" class="form-control"
							value="7"> <input name="cate_value" type="text"
							class="form-control" placeholder="생성할 용차업체를 입력하세요." required>
						<button class="btn btn-lg btn-primary" type="submit">생성</button>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!-- /container -->

	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
	<script src="./dist/js/bootstrap.min.js"></script>
	<script>
		requestCategoryData('2');
	</script>
</body>
</html>